//
//  UserAgreementViewController.swift
//  miaoyin
//
//  Created by David on 2017/4/5.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class UserAgreementViewController: UIViewController, UIWebViewDelegate {

    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }
    
    var webView: UIWebView!
    var loadingView: UIActivityIndicatorView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        webView = UIWebView(frame: CGRect(x: 0, y: 64, width: view.frame.width, height: view.frame.height-64))
        webView.loadRequest(URLRequest(url: URL(string: "\(baseDomainName)/print/agreement/useragreement.html")!))
        view.addSubview(webView)
        
        let navigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 64))
        view.addSubview(navigationBar)
        navigationBar.barStyle = .black
        navigationBar.barTintColor = Fatcat.THEME_COLOR
        navigationBar.tintColor = UIColor.white
        let navItem = UINavigationItem(title: "喵印使用协议")
        navItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(UserAgreementViewController.closeVC))
        navigationBar.pushItem(navItem, animated: true)
        
//        loadingView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
//        loadingView.center = view.center
//        loadingView.hidesWhenStopped = true
//        view.addSubview(loadingView)
//        loadingView.startAnimating()
    }
    
    func webViewDidFinishLoad(_ webView: UIWebView) {
        loadingView.stopAnimating()
    }
    
    func closeVC(){
        dismiss(animated: true, completion: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
